/*
 * @Author: 谢小康 2170673706@qq.com
 * @Date: 2023-11-23 17:24:07
 * @LastEditors: 谢小康 2170673706@qq.com
 * @LastEditTime: 2024-02-06 14:34:33
 * @FilePath: \my_bolg_admin\my_admin\vite.config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path';
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
  base: "/admin/",
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      /* 设置别名 */
      '@': path.resolve(__dirname, './src'),
    },
  },
  server: {
    port: 8080,
    host: "localhost",
    https: false,
    open: true,
   /*  proxy: {
      '/api': { // 匹配请求路径，localhost:3000/snow
        target: 'http://localhost:8088/', // 代理的目标地址
        changeOrigin: true, // 开发模式，默认的origin是真实的 origin:localhost:3000 代理服务会把origin修改为目标地址
        // secure: true, // 是否https接口
        // ws: true, // 是否代理websockets
        rewrite: (path) => path.replace(/^\/api/, ''),
        // rewrite target目标地址 + '/abc'，如果接口是这样的，那么不用重写
        // rewrite: (path) => path.replace(/^\/snow/, '') // 路径重写，本项目不需要重写
      }
    } */
  },
  build:{
    terserOptions: {
      compress: {
        drop_console: true, // 生产环境去掉控制台 console
        drop_debugger: true, // 生产环境去掉控制台 debugger 默认就是true
        dead_code: true, // 删除无法访问的代码 默认就是true
      }
    },
    chunkSizeWarningLimit: 2000, // 调整区块大小警告限制
  }
})
